﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using RSERV.Resx;
using System.ComponentModel;

namespace RSERV
{
    public partial class MainPage : UserControl
    {
        private ConnectToDbService.ConnectToDbServiceSoapClient cToDbser;
        public MainPage()
        {
            cToDbser = new ConnectToDbService.ConnectToDbServiceSoapClient();
            InitializeComponent();
            lblServer.Content = Resource.Server;
            lblDb.Content = Resource.Database;
            lblLogin.Content = Resource.Login;
            lblPass.Content = Resource.Password;
            btnSubmit.Content = Resource.Login;
            txtServer.Text = ".\\diveproject";
            txtDb.Text = "projectdivebe";
            txtLogin.Text = "test";
            txtPw.Password = "test";
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            cToDbser.GetConnectionCompleted += new EventHandler<ConnectToDbService.GetConnectionCompletedEventArgs>(cToDbser_GetConnectionCompleted);
            cToDbser.GetConnectionAsync(txtPw.Password, txtLogin.Text, txtServer.Text, txtDb.Text);
            //csc.GetConnectionCompleted += new EventHandler<ConnectService.GetConnectionCompletedEventArgs>(servrev_GetConnection);
            //csc.GetConnectionAsync(
            //App.Navigate(new Pages.Home());
        }

        void cToDbser_GetConnectionCompleted(object sender, ConnectToDbService.GetConnectionCompletedEventArgs e)
        {
            InstanceSettings.connection = e.Result;
            App.Navigate(new Pages.Home());
        }

        
    }
}
